home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-06 | 4.9 KB | 142 lines | [TEXT/MMCC] |
- //
- // CTCPResolverCall.h
- //
- // TurboTCP library
- // TCP resolver class
- //
- // Copyright © 1993-95, FrostByte Design / Eric Scouten
- //
-
- #pragma once
-
- #include "TurboTCP.buildflags.h"
- #include "CTCPDriver.h"
- #include "CTCPEndpoint.h"
-
-
- #if TurboTCP_UH2
- #include <MacTCP.h>
- #else
- #include <MacTCPCommonTypes.h>
- #include <AddressXlation.h>
- #define Result2UPP ResultProc2UPP
- #define NewResult2Proc NewResultProc2Proc
- #endif
-
-
- //***********************************************************
-
- class CTCPResolverCall {
-
- // This class implements the core DNR calls. It is like the CTCPAsyncCall in that the call
- // object is created to allow the call to persist beyond the scope of originating method.
- // However, access to this object is not restricted; your application classes can and often
- // will interact with the CTCPResolverCall object.
-
- // Each resolver object may support only one asynchronous resolver call at a time.
- // You may create several resolver objects to simultaneously process several calls,
- // so long as you respect MacTCP’s limit of 8 resolver calls open at once. The CTCPDriver
- // acts as a referee to prohibit more than 8 simultaneous calls.
-
- // One set of methods (Do...) is called to initiate resolver calls. These are the methods you
- // will typically call from your application classes. These methods initiate asynchronous
- // calls to the DNR code resource. When the calls are completed, the notification is passed
- // to another set of methods (Handle...). The Handle… methods return notification to your
- // class through the Handle… methods in CTCPProtcolInterp. The exception to this is the
- // DoAddrToStr method which returns the result immediately.
-
- // The userDataPtr fields of each of the calls are used by the resolver object to get
- // notification of completion, and are not available to the caller.
-
- // The CTCPDriver object takes care of opening and closing the DNR code resource; it uses
- // the OpenResolver and CloseResolver methods. You should not call these methods from your
- // application classes.
-
- // The EnumCache call is not implemented in TurboTCP.
-
- // TurboTCP 1.0 NOTE: This class is no longer a descendant of CCollaborator. It now
- // communicates only with the CTCPEndpoint mix-in class.
-
- friend class CTCPDriver;
- friend class CTCPResolverList;
- friend class UTurboTCP;
-
-
- public:
- CTCPResolverCall(CTCPEndpoint& theEndpoint);
- void Dispose();
- private:
- virtual ~CTCPResolverCall() {} // use Dispose() instead
-
- // initiate resolver calls
-
- public:
- void DoStrToAddr(char* theHostName);
- static void DoAddrToStr(ip_addr theIPaddr, char* theString);
- void DoAddrToName(ip_addr theIPaddr);
- void DoHInfo(char* theHostName);
- void DoMXInfo(char* theHostName);
-
- // respond to completion of resolver calls
-
- private:
- void ProcessNotify();
- inline void HandleStrToAddr()
- { if (itsEndpoint) itsEndpoint->HandleStrToAddr(&theHostInfo); }
- inline void HandleAddrToName()
- { if (itsEndpoint) itsEndpoint->HandleAddrToName(&theHostInfo); }
- inline void HandleHInfo()
- { if (itsEndpoint) itsEndpoint->HandleHInfo(&theHMXInfo); }
- inline void HandleMXInfo()
- { if (itsEndpoint) itsEndpoint->HandleMXInfo(&theHMXInfo); }
-
- // open/close TCP resolver
-
- static void OpenResolver();
- static void CloseResolver();
- static short OpenTheDNR();
- static short SearchFolderForDNRP(long targetType, long targetCreator, short vRefNum, long dirID);
- static void GetSystemFolder(short* vRefNumP, long* dirIDP);
- static void GetCPanelFolder(short* vRefNumP, long* dirIDP);
-
- // interrupt-level methods: delay processing for non-interrupt status
-
- void PostponeNotify(short theNotifType);
- static pascal void PostponeStrToAddr(hostInfo* hostInfoPtr, char* userDataPtr);
- static pascal void PostponeAddrToName(hostInfo* hostInfoPtr, char* userDataPtr);
- static pascal void PostponeHInfo(returnRec* returnRecPtr, char* userDataPtr);
- static pascal void PostponeMXInfo(returnRec* returnRecPtr, char* userDataPtr);
-
-
- // data members
-
- private:
- CTCPEndpoint* itsEndpoint; // endpoint object for this resolver
- Boolean inUse; // resolver in use; can’t accept calls
- Boolean disposeOnCompletion; // dispose of resolver call once completed
- hostInfo theHostInfo; // parms for StrToAddr
- returnRec theHMXInfo; // parms for HInfo or MXInfo
- char hostName[255]; // name of user host
- short pendingNotify; // resolver is in ProcessNotify queue
- static Handle macDNRcode; // the DNR code resource’s handle
- static UniversalProcPtr macDNRentry; // the DNR code entry point
- TurboTCPQElem qEntry; // completion queue entry
- TurboTCPQElem activeResListEntry; // completion queue entry
-
- #if TurboTCP_CFM
- static ResultUPP StrToAddrUPP; // UPPs for all DNR callbacks
- static ResultUPP AddrToNameUPP;
- static Result2UPP HInfoUPP;
- static Result2UPP MXInfoUPP;
- #endif
-
- enum {
- notifNone,
- notifStrToAddr,
- notifAddrToName,
- notifHInfo,
- notifMXInfo
- };
-
- };
-